<script setup>
import { ref } from 'vue'
import { Button } from './components'
import RequestDemo from './components/RequestDemo.vue'
import CatalogDemo from './components/CatalogDemo.vue'

const activeTab = ref('catalog')

const handleClick = () => {
  alert('按钮被点击了！')
}
</script>

<template>
  <div class="app-container">
    <h1>NB-UI 组件库演示</h1>
    
    <div class="tabs">
      <button 
        :class="['tab-button', { active: activeTab === 'button' }]"
        @click="activeTab = 'button'"
      >
        Button 按钮
      </button>
      <button 
        :class="['tab-button', { active: activeTab === 'catalog' }]"
        @click="activeTab = 'catalog'"
      >
        Catalog 目录
      </button>
      <button 
        :class="['tab-button', { active: activeTab === 'request' }]"
        @click="activeTab = 'request'"
      >
        Request 请求工具
      </button>
    </div>

    <section v-show="activeTab === 'button'" class="demo-section">
      <h2>Button 按钮组件</h2>
      
      <div class="demo-block">
        <h3>基础按钮</h3>
        <div class="button-group">
          <Button type="primary" @click="handleClick">主要按钮</Button>
          <Button type="success" @click="handleClick">成功按钮</Button>
          <Button type="warning" @click="handleClick">警告按钮</Button>
          <Button type="danger" @click="handleClick">危险按钮</Button>
          <Button type="info" @click="handleClick">信息按钮</Button>
          <Button type="default" @click="handleClick">默认按钮</Button>
        </div>
      </div>

      <div class="demo-block">
        <h3>朴素按钮</h3>
        <div class="button-group">
          <Button type="primary" plain @click="handleClick">主要按钮</Button>
          <Button type="success" plain @click="handleClick">成功按钮</Button>
          <Button type="warning" plain @click="handleClick">警告按钮</Button>
          <Button type="danger" plain @click="handleClick">危险按钮</Button>
          <Button type="info" plain @click="handleClick">信息按钮</Button>
        </div>
      </div>

      <div class="demo-block">
        <h3>圆角按钮</h3>
        <div class="button-group">
          <Button type="primary" round @click="handleClick">主要按钮</Button>
          <Button type="success" round @click="handleClick">成功按钮</Button>
          <Button type="warning" round @click="handleClick">警告按钮</Button>
          <Button type="danger" round @click="handleClick">危险按钮</Button>
          <Button type="info" round @click="handleClick">信息按钮</Button>
        </div>
      </div>

      <div class="demo-block">
        <h3>不同尺寸</h3>
        <div class="button-group">
          <Button type="primary" size="small" @click="handleClick">小型按钮</Button>
          <Button type="primary" size="medium" @click="handleClick">中等按钮</Button>
          <Button type="primary" size="large" @click="handleClick">大型按钮</Button>
        </div>
      </div>

      <div class="demo-block">
        <h3>禁用状态</h3>
        <div class="button-group">
          <Button type="primary" disabled>主要按钮</Button>
          <Button type="success" disabled>成功按钮</Button>
          <Button type="warning" disabled>警告按钮</Button>
          <Button type="danger" disabled>危险按钮</Button>
          <Button type="info" disabled>信息按钮</Button>
        </div>
      </div>
    </section>

    <section v-show="activeTab === 'catalog'" class="demo-section">
      <CatalogDemo />
    </section>

    <section v-show="activeTab === 'request'" class="demo-section">
      <RequestDemo />
    </section>
  </div>
</template>

<style scoped>
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid #e4e7ed;
}

.tab-button {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: #606266;
  transition: all 0.3s;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: #409eff;
}

.tab-button.active {
  color: #409eff;
  border-bottom-color: #409eff;
}

h1 {
  font-size: 32px;
  color: #303133;
  margin-bottom: 40px;
  text-align: center;
}

.demo-section {
  margin-bottom: 40px;
}

.demo-section > h2 {
  font-size: 24px;
  color: #303133;
  margin-bottom: 30px;
  padding-bottom: 10px;
  border-bottom: 2px solid #409eff;
}

.demo-block {
  margin-bottom: 30px;
  padding: 20px;
  background-color: #ffffff;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
}

.demo-block h3 {
  font-size: 18px;
  color: #606266;
  margin-bottom: 15px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

body {
  margin: 0;
  padding: 0;
  background-color: #f5f7fa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
</style>
